#pragma once
#ifndef skyPainter_h__
#define skyPainter_h__
#include "./skyAdapter.h"




#ifdef _SYMBIAN
#include "./symbian/symPainter.h"
#else
#include "./windows/winPainter.h"
#endif

namespace Sky
{
class Pict;
class Font;
class Canvas;
	class Layout
	{
	public:
		enum Align
		{
			left,
			right,
			middle,
			top,
			bottom,
			center
		};
	};
	
	class Painter : public Sky::OSPainter
	{
		DECL_RTTI1(Painter,OSPainter);
	public:
		Painter(void);
		~Painter(void){};
	public:
		NType::TBool	attachPict(Pict* pict);
		Pict* 	detachPict();

		NType::TBool	attachFont(Font* font);
		Font* 	detachFont();

		NType::TBool	attachCanvas(Canvas* canvas);
		Canvas* detachCanvas();

		NType::TBool begin();
		NType::TVoid end();

		NType::TVoid drawLine(TPoint& start,TPoint& end) ;
		NType::TVoid drawRect(TRect& rect);

		NType::TVoid fillRect(TRect& rect);
		NType::TVoid setPenColor(TColor color);
		NType::TVoid setBrushColor(TColor color);
		NType::TVoid drawPict(TRect& dstRect,Pict* pict,TRect* srcRect = vNull);
		NType::TVoid drawText(TRect& dstRect,const String* text,TColor color,Layout::Align align = Layout::left ) ;

		Pict* getPict(){return mpPict;};
		Font* getFont(){return mpFont;}
		Canvas* getCanvas(){return mCanvas;}

		virtual TSize	calTextSize(String* str,Font* font = vNull);

		virtual NType::TRect*	getClipArea();
		virtual NType::TVoid	setClipArea(TUint x,TUint y,TUint w,TUint h);
		virtual NType::TVoid	setClipArea(TRect* rect);

		virtual NType::TRect*	getInvalidArea();
		virtual NType::TVoid	setInvalidArea(TUint x,TUint y,TUint w,TUint h);
		virtual NType::TVoid	setInvalidArea(TRect* rect);
		virtual NType::TVoid	setInvalidObject(Object* object){mpObject = object;}

		NType::TBool fillWith(Pict* srcPict,NType::TRect* srcRect,NType::TRect* dstRect);
		NType::TBool mirrorWith(Pict* srcPict,Pict* dst,TUint MirrorType_);

		NType::TBool invalidate(NType::TRect* rect){mbNeedRedraw = vTrue; mInvalidRect = *rect;};
		NType::TBool isNeedRedraw(){return mbNeedRedraw;}
	private:
		NType::TBool			mbNeedRedraw;
		Pict*			mpPict;
		Canvas*			mCanvas;
		Object*			mpObject;
		Font*			mpFont;
		NType::TRect			mClipRect;
		NType::TRect			mInvalidRect;
	};
	typedef RefPtr<Painter> PainterPtr;
}
#endif // skyPainter_h__